{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# hvPlot.polygons\n",
    "\n",
    "```{eval-rst}\n",
    ".. currentmodule:: hvplot\n",
    "\n",
    ".. automethod:: hvPlot.polygons\n",
    "```\n",
    "\n",
    "## Backend-specific styling options\n",
    "\n",
    "```{eval-rst}\n",
    ".. backend-styling-options:: polygons\n",
    "```\n",
    "\n",
    "## Examples\n",
    "\n",
    "### Basic polygons plot\n",
    "\n",
    "In this example we display a very simple `polygons` plot, from a GeoPandas `GeoDataFrame` built from Shapely `Polygon`s."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import geopandas as gpd\n",
    "import hvplot.pandas  # noqa\n",
    "from shapely.geometry import Polygon\n",
    "\n",
    "poly1 = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)])\n",
    "poly2 = Polygon([(1, 1), (2, 1), (2, 2), (1, 2)])\n",
    "poly3 = Polygon([(2, 2), (3, 2), (3, 3), (2, 3)])\n",
    "\n",
    "gdf = gpd.GeoDataFrame({'geometry': [poly1, poly2, poly3]})\n",
    "\n",
    "gdf.hvplot.polygons()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Choropleth/thematic map with `c`\n",
    "\n",
    "The [`c`](option-c) option (alias for [`color`](option-color)) can be used to generate [choropleth](https://en.wikipedia.org/wiki/Choropleth_map) and thematic maps. While not strictly required for this dataset in WGS84, we set [`geo`](option-geo) to `True` to demonstrate that `polygons` support being displayed with GeoViews. We additionally set [`tiles`](option-tiles) to `True` to overlay the polygons on web map tiles.\n",
    "\n",
    "This first example sets the `logz` keyword to `True`, as there are a few states with very low and high population densities, that would make a linear scale inappropriate (this is equivalent to setting the [`cnorm`](option-cnorm) to `'log'`)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "\n",
    "gdf = hvplot.sampledata.us_states(\"geopandas\")\n",
    "\n",
    "gdf.hvplot.polygons(\n",
    "    color=\"pop_density\", logz=True, data_aspect=1, geo=True, tiles=True,\n",
    "    frame_width=500, title=\"Choropleth map\", clabel=\"Population density\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "\n",
    "gdf = hvplot.sampledata.us_states(\"geopandas\")\n",
    "\n",
    "gdf.hvplot.polygons(\n",
    "    color=\"bea_region\", data_aspect=1, geo=True, tiles=True,\n",
    "    frame_width=500, title=\"Thematic map\",\n",
    ")"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
